/**
 * @description: 使用 script setup 语法在 Taro3 实现小程序页面生命周期方法
 */
import { onMounted } from 'vue';

import { getCurrentInstance } from '@tarojs/taro';

const Current = getCurrentInstance();

export const useDidShow = (callback) => {
  onMounted(callback);
  if (Current?.page?.onShow) {
    Current.page.onShow = callback;
  }
};
export const usePullDownRefresh = (callback) => {
  if (Current?.page?.onPullDownRefresh) {
    Current.page.onPullDownRefresh = callback;
  }
};
export const useReachBottom = (callback) => {
  if (Current?.page?.onReachBottom) {
    Current.page.onReachBottom = callback;
  }
};
